package com.woniuxy.service.impl;

import com.woniuxy.entity.Camp;
import com.woniuxy.entity.CampExample;
import com.woniuxy.mapper.CampMapper;
import com.woniuxy.service.CampService;
import com.woniuxy.vo.CampVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/*
 * 营地住宿实现类
 */
@Service
public class CampServiceImpl implements CampService {
    @Resource
    private CampMapper campMapper;

    @Override
    public List<Camp> selectAllCamp() {
        return campMapper.selectByExample(null);
    }

    @Override
    public List<CampVO> selectCampByExample(Map<String, Object> map) {
        return campMapper.selectCampByExample(map);
    }

    @Override
    public List<Camp> selectCampByCityId(Integer cityId) {
        CampExample campExample = new CampExample();
        CampExample.Criteria criteria = campExample.createCriteria();
        criteria.andCityIdEqualTo(cityId);
        return this.campMapper.selectByExample(campExample);
    }

    @Override
    public Camp selectCampByCampId(Integer campId) {
        return campMapper.selectByPrimaryKey(campId);
    }

    @Override
    public int selectCampIdByCampName(String campName) throws Exception {
        return campMapper.selectCampIdBycampName(campName);
    }
    @Override
    public List<CampVO> selectAllCampVO() throws Exception {
        return campMapper.selectAllCampVO();
    }

}
